//    Copyright (C) Clear Office.  All rights reserved.
using System;
using System.Collections.Generic;
using Office.Core.Serialization;

namespace Office.Spreadsheet.PivotTable
{
    internal class Record : IOfficeXmlSerializable
    {
        internal const string xmlName = "r";
        readonly List<PivotTableValue> _values = new List<PivotTableValue>();

        #region IOfficeXmlSerializable Members

        public void ReadXml(ReadContext context)
        {
            using (ReadContext c = context.Read(xmlName))
            {
                _values.Clear();
                while (c.ReaderLocalName != null)
                    _values.Add(PivotTableValue.Read(c));
            }
        }

        public void WriteXml(WriteContext context)
        {
            using (WriteContext c = context.Write(xmlName))
            {
                c.WriteElements(_values);
            }
        }

        #endregion
    }
}